#ifndef _SYS_UART_H_
#define _SYS_UART_H_

#include "stm32f1_basic_func.h"
#include "app.h"

#define USART_REC_LEN  			200
typedef enum _baudrate
{
    baudrate_9600 = 9600,
    baudrate_115200 = 115200,
}BAUDRATE;
#if 1
#define SYS_USMART_GPIO_PeriphClockFunc     RCC_APB2PeriphClockCmd
#define SYS_USMART_GPIO_PeriphClock         RCC_APB2Periph_GPIOA
#define SYS_USMART_GPIO_PORT                GPIOA
#define SYS_USMART_GPIO_TXD                 GPIO_Pin_9
#define SYS_USMART_GPIO_TXD_AF              GPIO_PinSource9
#define SYS_USMART_GPIO_RXD                 GPIO_Pin_10
#define SYS_USMART_GPIO_RXD_AF              GPIO_PinSource10

#define SYS_USMART_PeriphClockFunc          RCC_APB2PeriphClockCmd
#define SYS_USMART_PeriphClock              RCC_APB2Periph_USART1
#define SYS_USMART_USARTx                   USART1
#define SYS_USMART_USARTx_IRQ               USART1_IRQn
#define SYS_USMART_USARTx_IRQ_Handler       USART1_IRQHandler
#else
#define SYS_USMART_GPIO_PeriphClockFunc     RCC_AHB1PeriphClockCmd
#define SYS_USMART_GPIO_PeriphClock         RCC_AHB1Periph_GPIOA
#define SYS_USMART_GPIO_PORT                GPIOA
#define SYS_USMART_GPIO_TXD                 GPIO_Pin_2
#define SYS_USMART_GPIO_TXD_AF              GPIO_PinSource2
#define SYS_USMART_GPIO_RXD                 GPIO_Pin_3
#define SYS_USMART_GPIO_RXD_AF              GPIO_PinSource3

#define SYS_USMART_PeriphClockFunc          RCC_APB1PeriphClockCmd
#define SYS_USMART_USARTx                   SART2
#define SYS_USMART_PeriphClock              RCC_APB1Periph_USART2
#define SYS_USMART_USARTx_IRQ               USART2_IRQn
#define SYS_USMART_USARTx_IRQ_Handler       USART2_IRQHandler
#endif

#define CHKFILE                 printf("CHKFILE: %d\t%s\r\n",__LINE__,__FILE__)
#define CHKPNT                  printf("\nCHK:func:%s Line:%d\r\n",__FUNCTION__,__LINE__)
#define DBG_MSG(fmt,arg...)     printf(""fmt"",##arg)
#define DBG_ERR(fmt,arg...)     printf("ERR:"fmt"",##arg)
#define DBG_INFO(fmt,arg...)    printf(" %s() "fmt"",__FUNCTION__,##arg)

void sys_uart_init(BAUDRATE boundrate);
uint8_t sys_usmart_getstring(uint8_t *rx_str);

#endif
